#ifndef CAR_POWER_RANGE_H
#define CAR_POWER_RANGE_H

#include "car_power_range_struct_csv.hpp"

class car_power_range
{
  public:
	inline virtual ~car_power_range() { };
/*
	virtual bool exist(int _id) =0;
	virtual bool exist(int _min, int _max) =0;
	virtual int min_power(int _id) = 0;
	virtual int max_power(int _id) = 0;
	virtual std::string const descr(int _id) =0;
	*/
	// find power class amongst defined ranges
	//static int find_power_range_id(int _range[]);

  private:
};



// implementation for csv files

class car_power_range_csv: public car_power_range
{
  public:
	inline car_power_range_csv(char* filename): file(filename)
	{ }

	inline car_power_range_csv(std::string filename): file(filename)
	{}

	car_power_range_csv();

	static int find_power_range_id(int _range[]);	

  protected:

	static car_power_range_struct_csv const find(int _id);	
	static car_power_range_struct_csv const find(int _min, int _max);	


  private:
	std::string file;
        car_power_range_struct_csv line;
};
/*
template <class table_method, class table_line> struct find_id: std::binary_function<table_method*, std::pair<int, table_line&>, bool>
{
	public:
		bool operator() (table_method* _table, std::pair<int, table_line*> _ref) const
		{
			csv_struct csv_table(_table->filename()); // csv reference table
			
			while (!csv_table.eof())
			{
				++csv_table;
				_table->init_line(csv_table.get_line());
				if(_table->get_line().id() == _ref.first)
				{
					_ref.second = _table->get_line();
					return true;
				}
			}
			return false;
		}
		
};


template <class table_method, class table_line> struct find_range: 
	std::binary_function<table_method*, std::pair< std::vector<int>, table_line& >, bool>
{
	public:
		bool operator() (table_method* _table, std::pair<std::vector<int>,table_line&> _ref) const
		{
			csv_struct csv_table(_table->filename()); // csv reference table
			while (!csv_table.eof())
			{
				++csv_table;
				_table->init_line(csv_table.get_line());
				if(_table->get_line().min() == _ref.first[0] && _table->get_line().max() == _ref.first[1])
				{
					_ref.second = _table->get_line();
					return true;
				}
			}
			return false;
		}
};
*/
#endif
